package train.Test;

import java.io.IOException;
import java.util.*;

public class test {

        public  static void main(String[] args) throws IOException {

            //入栈符号匹配
            Stack<Character> stack = new Stack<>();
            Scanner scanner = new Scanner(System.in);
            String next = scanner.next();
            boolean k=true;
            String a="";
            for (int i = 0; i < next.length(); i++) {
                char c = next.charAt(i);
                if(c=='('||c=='['||c=='{')
                    stack.push(c);
                else {
                      if(i==0){
                          stack.push(c);
                      }
                    switch(c){
                        case ')' :
                                  if(!stack.empty()&&stack.peek()=='(') stack.pop();break;
                        case '}' :
                                 if(!stack.empty()&&stack.peek()=='{') stack.pop();break;
                        case ']' :
                                 if(!stack.empty()&&stack.peek()=='[') stack.pop();break;
                    }

                }
            }
            if(stack.empty())
                System.out.println("true");
            else

            System.out.println("false");
        }
}
